package org.dandelion.memo.dao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBHelper extends SQLiteOpenHelper {
    public DBHelper(@Nullable Context context, @Nullable String name,
                    @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        MemoCategoryDao.getInstance().createTable(db);
        MemoDao.getInstance().createTable(db);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        MemoDao.getInstance().dropTable(db);
        MemoCategoryDao.getInstance().dropTable(db);
        MemoCategoryDao.getInstance().createTable(db);
        MemoDao.getInstance().createTable(db);
    }
}
